package com.yuan.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yuandong
 * @date 2021/5/8 9:17
 */
@Configuration
public class RabbitConfig {

    /**
     * 声明一个交换机
     * @return
     */
    @Bean
    public DirectExchange setHelloExchange() {
        return new DirectExchange("hello_exchange");
    }

    /**
     *声明一个队列
     * @return
     */
    @Bean
    public Queue helloQueue(){
        return new Queue("hello_queue");
    }


    /**
     * 绑定交换机和队列
     * @return
     */
    @Bean
    public Binding crewDirectBind1() {
        return BindingBuilder.bind(helloQueue()).to(setHelloExchange()).with("hello");
    }

}
